<html>
<head><meta charset="utf-8"><title>inspiration for new mir opts · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html">inspiration for new mir opts</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="222899097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222899097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222899097">(Jan 15 2021 at 18:06)</a>:</h4>
<p>If someone wants inspiration for something we should optimize in MIR (that LLVM already optimizes right now), have a look at <a href="https://github.com/rust-lang/rust/blob/a0c585713174711b00f56c0f2ffe480ab878e8dc/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir">https://github.com/rust-lang/rust/blob/a0c585713174711b00f56c0f2ffe480ab878e8dc/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir</a></p>



<a name="222899127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222899127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222899127">(Jan 15 2021 at 18:07)</a>:</h4>
<p>that test has several different things that we need to optimize</p>



<a name="222899281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222899281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222899281">(Jan 15 2021 at 18:08)</a>:</h4>
<div class="codehilite"><pre><span></span><code>        _10 = discriminant((*_6));       // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
        _2 = Eq(_10, const 1_isize);     // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
        switchInt(move _2) -&gt; [false: bb2, otherwise: bb1]; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63
</code></pre></div>
<p>I thought we already had something for this, so maybe we just need to turn up the optimization level on that test</p>



<a name="222899451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222899451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222899451">(Jan 15 2021 at 18:09)</a>:</h4>
<p>calling a const fn twice with the same arguments should definitely only call it once (<code>to_digits</code> calls)</p>



<a name="222899529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222899529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222899529">(Jan 15 2021 at 18:09)</a>:</h4>
<p>variable <code>_5</code> isn't optimized out</p>



<a name="222900773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222900773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222900773">(Jan 15 2021 at 18:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/inspiration.20for.20new.20mir.20opts/near/222899451">said</a>:</p>
<blockquote>
<p>calling a const fn twice with the same arguments should definitely only call it once (<code>to_digits</code> calls)</p>
</blockquote>
<p>What about <code>const_allocate</code>?</p>



<a name="222901039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222901039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222901039">(Jan 15 2021 at 18:19)</a>:</h4>
<p>uuuh <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="222901169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222901169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222901169">(Jan 15 2021 at 18:20)</a>:</h4>
<p>this is gonna be curious... LLVM manages this optimization, so... we'll need to see how/whether we can do it, too</p>



<a name="222901221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222901221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222901221">(Jan 15 2021 at 18:20)</a>:</h4>
<p>I mean... in contrast to user visible changes, optimizations are allowed to look at function bodies</p>



<a name="222901274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222901274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222901274">(Jan 15 2021 at 18:21)</a>:</h4>
<p>since all that can happen is that we have perf regressions if we stop looking at the function bodies, instead of breaking compiling code</p>



<a name="222901634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222901634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222901634">(Jan 15 2021 at 18:23)</a>:</h4>
<p>Hmm, <code>_5</code> local removal should be handled by <code>ConstDebugInfo</code> already. Oh, it was disabled :(.</p>



<a name="222901754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222901754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222901754">(Jan 15 2021 at 18:24)</a>:</h4>
<p>Yeah, I have no idea what's going on with the Windows failures for <code>ConstDebugInfo</code></p>



<a name="222902871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222902871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222902871">(Jan 15 2021 at 18:31)</a>:</h4>
<p>What about a) removing locals used only by var debug info at debuginfo != 2? Alternatively, b) removing var debug info altogether at debuginfo != 2.</p>



<a name="222905574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/inspiration%20for%20new%20mir%20opts/near/222905574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/inspiration.20for.20new.20mir.20opts.html#222905574">(Jan 15 2021 at 18:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="352985">tm</span> <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/inspiration.20for.20new.20mir.20opts/near/222902871">said</a>:</p>
<blockquote>
<p>What about a) removing locals used only by var debug info at debuginfo != 2? Alternatively, b) removing var debug info altogether at debuginfo != 2.</p>
</blockquote>
<p>Gcc has the nice property that changing the debuginfo level doesn't affect codegen at all. This makes it easy to recompile with debuginfo when a build without crashes due to UB. Removing var debuginfo when it isn't used, can affect codegen.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>